import React,{useEffect}from "react";
import {useHistory,useLocation} from 'react-router-dom'
function yztoken(Com:React.FC) {
  return function Yztoken() {
    let history=useHistory()
    let location=useLocation()
    useEffect(()=>{
        if(location.pathname!=='/login'){
            let token=localStorage.getItem('token')
            if(!token){
                history.push('/login')
            }
        }
    },[])
    return <Com/>
  };
}
export default yztoken